extends Base1
var RUN_SPEED=50.00
var player_position = Vector2()
var original_scale = Vector2(1, 1) # Store the original scale
var is_parasiting = false

@onready var monster=$"../.."
@onready var ani_sprite:AnimatedSprite2D=$"../../Graphics/AnimatedSprite2D"
@onready var detection_area: Area2D = $"../../Detection_area"
@onready var attack_area = $"../../AttackArea"

var delta=get_physics_process_delta_time()
func enter():
	original_scale = ani_sprite.scale
	ani_sprite.play("attack")
	pass
func do():
	if player_position != Vector2.ZERO:
		move_towards_player(delta)
	else:
		get_parent().change_state(0)
	monster.move_and_slide()

func move_towards_player(delta):
	var direction = (player_position - monster.position).normalized()
	monster.position += direction * RUN_SPEED * delta
	if is_parasiting:
		# Change sprite and scale if parasiting
		ani_sprite.scale = original_scale * 2
	else:
		ani_sprite.scale = original_scale


func parasite_enemy(new_sprite_frames: SpriteFrames):
	ani_sprite.frames = new_sprite_frames
	is_parasiting = true
	pass
